home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / generic / tkMenubutton.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  7.6 KB  |  208 lines  |  [TEXT/CWIE]

  1. /*
  2.  * tkMenubutton.h --
  3.  *
  4.  *    Declarations of types and functions used to implement
  5.  *    the menubutton widget.
  6.  *
  7.  * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * SCCS: @(#) tkMenubutton.h 1.3 97/04/11 11:24:15
  13.  */
  14.  
  15. #ifndef _TKMENUBUTTON
  16. #define _TKMENUBUTTON
  17.  
  18. #ifndef _TKINT
  19. #include "tkInt.h"
  20. #endif
  21.  
  22. /*
  23.  * A data structure of the following type is kept for each
  24.  * widget managed by this file:
  25.  */
  26.  
  27. typedef struct {
  28.     Tk_Window tkwin;        /* Window that embodies the widget.  NULL
  29.                  * means that the window has been destroyed
  30.                  * but the data structures haven't yet been
  31.                  * cleaned up.*/
  32.     Display *display;        /* Display containing widget.  Needed, among
  33.                  * other things, so that resources can bee
  34.                  * freed up even after tkwin has gone away. */
  35.     Tcl_Interp *interp;        /* Interpreter associated with menubutton. */
  36.     Tcl_Command widgetCmd;    /* Token for menubutton's widget command. */
  37.     char *menuName;        /* Name of menu associated with widget.
  38.                  * Malloc-ed. */
  39.  
  40.     /*
  41.      * Information about what's displayed in the menu button:
  42.      */
  43.  
  44.     char *text;            /* Text to display in button (malloc'ed)
  45.                  * or NULL. */
  46.     int underline;        /* Index of character to underline. */
  47.     char *textVarName;        /* Name of variable (malloc'ed) or NULL.
  48.                  * If non-NULL, button displays the contents
  49.                  * of this variable. */
  50.     Pixmap bitmap;        /* Bitmap to display or None.  If not None
  51.                  * then text and textVar and underline
  52.                  * are ignored. */
  53.     char *imageString;        /* Name of image to display (malloc'ed), or
  54.                  * NULL.  If non-NULL, bitmap, text, and
  55.                  * textVarName are ignored. */
  56.     Tk_Image image;        /* Image to display in window, or NULL if
  57.                  * none. */
  58.  
  59.     /*
  60.      * Information used when displaying widget:
  61.      */
  62.  
  63.     Tk_Uid state;        /* State of button for display purposes:
  64.                  * normal, active, or disabled. */
  65.     Tk_3DBorder normalBorder;    /* Structure used to draw 3-D
  66.                  * border and background when window
  67.                  * isn't active.  NULL means no such
  68.                  * border exists. */
  69.     Tk_3DBorder activeBorder;    /* Structure used to draw 3-D
  70.                  * border and background when window
  71.                  * is active.  NULL means no such
  72.                  * border exists. */
  73.     int borderWidth;        /* Width of border. */
  74.     int relief;            /* 3-d effect: TK_RELIEF_RAISED, etc. */
  75.     int highlightWidth;        /* Width in pixels of highlight to draw
  76.                  * around widget when it has the focus.
  77.                  * <= 0 means don't draw a highlight. */
  78.     XColor *highlightBgColorPtr;
  79.                 /* Color for drawing traversal highlight
  80.                  * area when highlight is off. */
  81.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  82.     int inset;            /* Total width of all borders, including
  83.                  * traversal highlight and 3-D border.
  84.                  * Indicates how much interior stuff must
  85.                  * be offset from outside edges to leave
  86.                  * room for borders. */
  87.     Tk_Font tkfont;        /* Information about text font, or NULL. */
  88.     XColor *normalFg;        /* Foreground color in normal mode. */
  89.     XColor *activeFg;        /* Foreground color in active mode.  NULL
  90.                  * means use normalFg instead. */
  91.     XColor *disabledFg;        /* Foreground color when disabled.  NULL
  92.                  * means use normalFg with a 50% stipple
  93.                  * instead. */
  94.     GC normalTextGC;        /* GC for drawing text in normal mode. */
  95.     GC activeTextGC;        /* GC for drawing text in active mode (NULL
  96.                  * means use normalTextGC). */
  97.     Pixmap gray;        /* Pixmap for displaying disabled text/icon if
  98.                  * disabledFg is NULL. */
  99.     GC disabledGC;        /* Used to produce disabled effect.  If
  100.                  * disabledFg isn't NULL, this GC is used to
  101.                  * draw button text or icon.  Otherwise
  102.                  * text or icon is drawn with normalGC and
  103.                  * this GC is used to stipple background
  104.                  * across it. */
  105.     int leftBearing;        /* Distance from text origin to leftmost drawn
  106.                  * pixel (positive means to right). */
  107.     int rightBearing;        /* Amount text sticks right from its origin. */
  108.     char *widthString;        /* Value of -width option.  Malloc'ed. */
  109.     char *heightString;        /* Value of -height option.  Malloc'ed. */
  110.     int width, height;        /* If > 0, these specify dimensions to request
  111.                  * for window, in characters for text and in
  112.                  * pixels for bitmaps.  In this case the actual
  113.                  * size of the text string or bitmap is
  114.                  * ignored in computing desired window size. */
  115.     int wrapLength;        /* Line length (in pixels) at which to wrap
  116.                  * onto next line.  <= 0 means don't wrap
  117.                  * except at newlines. */
  118.     int padX, padY;        /* Extra space around text or bitmap (pixels
  119.                  * on each side). */
  120.     Tk_Anchor anchor;        /* Where text/bitmap should be displayed
  121.                  * inside window region. */
  122.     Tk_Justify justify;        /* Justification to use for multi-line text. */
  123.     int textWidth;        /* Width needed to display text as requested,
  124.                  * in pixels. */
  125.     int textHeight;        /* Height needed to display text as requested,
  126.                  * in pixels. */
  127.     Tk_TextLayout textLayout;    /* Saved text layout information. */
  128.     int indicatorOn;        /* Non-zero means display indicator;  0 means
  129.                  * don't display. */
  130.     int indicatorHeight;    /* Height of indicator in pixels.  This same
  131.                  * amount of extra space is also left on each
  132.                  * side of the indicator. 0 if no indicator. */
  133.     int indicatorWidth;        /* Width of indicator in pixels, including
  134.                  * indicatorHeight in padding on each side.
  135.                  * 0 if no indicator. */
  136.  
  137.     /*
  138.      * Miscellaneous information:
  139.      */
  140.  
  141.     Tk_Uid direction;        /* Direction for where to pop the menu.
  142.                      * Valid directions are "above", "below",
  143.                      * "left", "right", and "flush". "flush"
  144.                      * means that the upper left corner of the
  145.                      * menubutton is where the menu pops up.
  146.                      * "above" and "below" will attempt to pop
  147.                      * the menu compleletly above or below
  148.                      * the menu respectively.
  149.                      * "left" and "right" will pop the menu
  150.                      * left or right, and the active item
  151.                      * will be next to the button. */
  152.     Tk_Cursor cursor;        /* Current cursor for window, or None. */
  153.     char *takeFocus;        /* Value of -takefocus option;  not used in
  154.                  * the C code, but used by keyboard traversal
  155.                  * scripts.  Malloc'ed, but may be NULL. */
  156.     int flags;            /* Various flags;  see below for
  157.                  * definitions. */
  158. } TkMenuButton;
  159.  
  160. /*
  161.  * Flag bits for buttons:
  162.  *
  163.  * REDRAW_PENDING:        Non-zero means a DoWhenIdle handler
  164.  *                has already been queued to redraw
  165.  *                this window.
  166.  * POSTED:            Non-zero means that the menu associated
  167.  *                with this button has been posted (typically
  168.  *                because of an active button press).
  169.  * GOT_FOCUS:            Non-zero means this button currently
  170.  *                has the input focus.
  171.  */
  172.  
  173. #define REDRAW_PENDING        1
  174. #define POSTED            2
  175. #define GOT_FOCUS        4
  176.  
  177. /*
  178.  * The following constants define the dimensions of the cascade indicator,
  179.  * which is displayed if the "-indicatoron" option is true.  The units for
  180.  * these options are 1/10 millimeters.
  181.  */
  182.  
  183. #define INDICATOR_WIDTH        40
  184. #define INDICATOR_HEIGHT    17
  185.  
  186. /*
  187.  * Declaration of variables shared between the files in the button module.
  188.  */
  189.  
  190. extern TkClassProcs tkpMenubuttonClass;
  191.  
  192. /*
  193.  * Declaration of procedures used in the implementation of the button
  194.  * widget. 
  195.  */
  196.  
  197. EXTERN void        TkpComputeMenuButtonGeometry _ANSI_ARGS_((
  198.                 TkMenuButton *mbPtr));
  199. EXTERN TkMenuButton *    TkpCreateMenuButton _ANSI_ARGS_((Tk_Window tkwin));
  200. EXTERN void        TkpDisplayMenuButton _ANSI_ARGS_((
  201.                 ClientData clientData));
  202. EXTERN void         TkpDestroyMenuButton _ANSI_ARGS_((
  203.                 TkMenuButton *mbPtr));
  204. EXTERN void        TkMenuButtonWorldChanged _ANSI_ARGS_((
  205.                 ClientData instanceData));
  206.  
  207. #endif /* _TKMENUBUTTON */
  208.